package org.tulkas.task;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;

import org.tulkas.config.BasicConfig;
import org.tulkas.util.IAsyncHolder;

/**
 * @author <a href="mailto:tulkas.web@gmail.com">Tulkas</a>
 *
 */
public class TaskContext {
	private long taskId;

	private BasicConfig taskConfig;

	private ExecutorService asyncExecutor;

	private IAsyncHolder asyncHolder;

	private final Map<String, Object> attributes = new HashMap<String, Object>();

	public long getTaskId() {
		return taskId;
	}

	public void setTaskId(long taskId) {
		this.taskId = taskId;
	}

	public BasicConfig getTaskConfig() {
		return taskConfig;
	}

	public void setTaskConfig(BasicConfig taskConfig) {
		this.taskConfig = taskConfig;
	}

	public ExecutorService getAsyncExecutor() {
		return asyncExecutor;
	}

	public void setAsyncExecutor(ExecutorService asyncExecutor) {
		this.asyncExecutor = asyncExecutor;
	}

	public IAsyncHolder getAsyncRepository() {
		return asyncHolder;
	}

	public void setAsyncRepository(IAsyncHolder asyncRepository) {
		this.asyncHolder = asyncRepository;
	}

	public Object getAttribute(String key) {
		return attributes.get(key);
	}

	public void setAttribute(String key, Object value) {
		attributes.put(key, value);
	}

	public String[] getAttributeKeys() {
		return attributes.keySet().toArray(new String[attributes.size()]);
	}

	public void clearAttributes() {
		attributes.clear();
	}
}
